<%@ page language="java" import="com.emp.database.*,java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%	
	//重新指定提交的编码格式
	request.setCharacterEncoding("utf-8");
	String username =request.getParameter("username");
	System.out.print(username);
	
	String password =request.getParameter("password");
	String ck = request.getParameter("ck");
	
	LoginOperate lo = new LoginOperate();
	int flag = lo.checkLogin(username,password);
	
	if(flag == 1){
		if(ck!=null&&ck.equals("on")){
			Cookie c1=new Cookie("username",username);
			Cookie c2=new Cookie("password",password);
			//设置Cookie时间
			c1.setMaxAge(24*3600);
			c2.setMaxAge(24*3600);
			//将Cookie写入客户端磁盘
			response.addCookie(c1);
			response.addCookie(c2);
		}
		
		Integer it=(Integer)application.getAttribute("count");
		if(it == null){
			application.setAttribute("count", 1);
		}else{
			it+=1;
			application.setAttribute("count", it);
		}
		session.setAttribute("uname",username);
		request.getRequestDispatcher("manager/manager.jsp").forward(request, response);
	}else{
		
		request.setAttribute("message", "用户名或密码错误");
		
		
		request.getRequestDispatcher("Login.jsp").forward(request, response);
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>验证</title>
</head>
<body>

</body>
</html>